 
layui.define(['form','laydate','xmSelect'], function(exports){
	var $ = layui.$
    ,setter = layui.setter

	// layui.laydate.render({
	// 	elem: "#confirmArrivalTime",
	// 	type: "datetime",
	// 	format: "yyyy-MM-dd HH:mm"
	// })

		// //获取input输入的值
		// if($("[name='confirmArrivalTime']").val()!=="" && $("[name='confirmOverTime']").val()!==""){
		// 		layui.admin.req({
		// 			url: setter.host + '/reservation/receiveManager/getAllFreePlatformByTime'
		// 			,type:'post'
		// 			,contentType: "application/x-www-form-urlencoded"
		// 			,data:{
		// 				startTime:$("[name='confirmArrivalTime']").val(),
		// 				keepTime:(Number)($("[name='confirmOverTime']").val())
		// 			}
		// 			,done: function(res){
		// 				//请求成功后
		// 				if(res.code == 0){
		// 					$("#platform option").remove()
		// 					for(let r of res.data){
		// 						if(r.sure===1){
		// 							console.log("可以选择")
		// 							$("#actualPlatformNumber").append(`<option value="${r.platformNumber}">${r.platformCode}号月台</option>`)
		// 						}else {
		// 							console.log("不能选择")
		// 							$("#actualPlatformNumber").append(`<option disabled="disabled" value="${r.platformNumber}">${r.platformCode}号月台</option>`)
		// 						}
		// 					}
		// 					layui.form.render('select');
		// 				}else{
		// 					layer.msg(res.msg);
		// 				}
		// 			}
		// 		})
		//
		// }



		//获取input输入的值
		// if($("[name='confirmArrivalTime']").val()!=="" && $("[name='confirmOverTime']").val()!==""){
		// 	layui.admin.req({
		// 		url: setter.host + '/reservation/receiveManager/getAllFreeReceiverByTime'
		// 		,type:'post'
		// 		,contentType: "application/x-www-form-urlencoded"
		// 		,data:{
		// 			startTime:$("[name='confirmArrivalTime']").val(),
		// 			keepTime:(Number)($("[name='confirmOverTime']").val())
		// 		}
		// 		,done: function(res){
		// 			//请求成功后
		// 			if(res.code == 0){
		// 				$("#receiver option").remove()
		// 				for(let r of res.data){
		// 					if(r.sure===1){
		// 						console.log("可以选择")
		// 						$("#actualReceiverNumber").append(`<option value="${r.receiverNumber}">${r.receiverName}</option>`)
		// 					}else {
		// 						console.log("不能选择")
		// 						$("#actualReceiverNumber").append(`<option disabled="disabled" value="${r.receiverNumber}">${r.receiverName}</option>`)
		// 					}
		// 					// $('[name="platform"]').options.add(new Option(r.platformCode+"号月台",r.platformNumber))
		// 				}
		// 				layui.form.render('select');
		// 			}else{
		// 				layer.msg(res.msg);
		// 			}
		// 		}
		// 	})
		//
		// }

	if ($("[name='confirmArrivalTime']").val() !== "" && $("[name='confirmOverTime']").val() !== "") {
		layui.admin.req({
			url: setter.host + '/reservation/receiveManager/freePlatformByTime'
			, type: 'post'
			, contentType: "application/x-www-form-urlencoded"
			, data: {
				startTime: $("#confirmArrivalTime").val(),
				keepTime: Number($("#durationTime").val())
			}
			, done: function (res) {
				//请求成功后
				if (res.code == 0) {
					$(`[id=platform] option`).remove()
					for (let r of res.data) {
						// for (let i = 0; i < Number($("#driverCount").val())-1; i++) {
						if (r.sure === 1) {
							console.log("可以选择")
							console.log($("#platform"))
							$(`[id=platform]`).append(`<option value="${r.platformNumber}">${r.platformCode}</option>`)
						} else {
							console.log("不能选择")
							$(`[id=platform]`).append(`<option disabled="disabled" value="${r.platformNumber}">${r.platformCode}</option>`)
						}
						// }

						// $('[name="platform"]').options.add(new Option(r.platformCode+"号月台",r.platformNumber))
					}
					layui.form.render('select');
					// $('#reservationNumber').val(res.data.reservationNumber);
					// $('#driverNumber').val(res.data.driverNumber);
					// $('#supplierNumber').val(res.data.supplierNumber);
					// $('#orderNumber').val(res.data.orderNumber);
					// $('#estimatedTimeOfArrival').val(res.data.estimatedTimeOfArrival);
					// $('#confirmOverTime').val(30);
					// $('#estimatedPlatformNumber').val(res.data.estimatedPlatformNumber);
					// $('#estimatedReceiverNumber').val(res.data.estimatedReceiverNumber);
					// $('#trayCount').val(res.data.trayCount);
				} else {
					layer.msg(res.msg);
				}
			}
		})

		layui.admin.req({
			url: setter.host + '/reservation/receiveManager/freeReceiverByTime'
			, type: 'post'
			, contentType: "application/x-www-form-urlencoded"
			, data: {
				startTime: $("#confirmArrivalTime").val(),
				keepTime: Number($("#durationTime").val())
			}
			, done: function (res) {
				$(`[id =receiver] option`).remove()
				if (res.code == 0) {
					for (let r of res.data) {
						// for (let i = 0; i < Number($("#driverCount").val())-1; i++) {
						if (r.sure === 1) {
							console.log("可以选择")
							$(`[id=receiver]`).append(`<option value="${r.receiverNumber}">${r.receiverName}</option>`)
						} else {
							console.log("不能选择")
							$(`[id=receiver]`).append(`<option disabled="disabled" value="${r.receiverNumber}">${r.receiverName}</option>`)
						}
						// }
					}
					layui.form.render('select');
				} else {
					layer.msg(res.msg);
				}
			}
		})

	}

  //对外暴露的接口
    exports('chidao', {});
});